package cn.sh.tools.service.component.swagger;

import cn.sh.tools.util.BrowserUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @Description 打开 swagger界面
 * @Classname SwaggerBrowserLauncher
 * @Date 2023/7/25
 * @Author sh
 **/
@Component
@Slf4j
public class SwaggerBrowserLauncher {

    @Value("${sh-swagger-ui-browser.enabled}")
    private Boolean enabled;

    @Value("${sh-swagger-ui-browser.browser_path}")
    private String browserPath;

    @Value("${sh-swagger-ui-browser.swagger_uri}")
    private String swaggerUri;

    @PostConstruct
    public void init() {
        if (enabled) {
            BrowserUtils.openURL(browserPath, swaggerUri);
        }
    }

}
